package test

import (
	"fmt"
	"github.com/gin-gonic/gin"
	"shopstar/core/cache"
	"time"
)

func GetCache(ctx *gin.Context) {
	key := ctx.Query("name")
	d, e := cache.CacheManager.Get(key)

	if e != nil {
		fmt.Println("err : ", e)
		ctx.String(200, "错误")
		return
	}
	fmt.Println("name : ", string(d.([]byte)))
	ctx.String(200, string(d.([]byte)))
}

func SetCache(ctx *gin.Context) {
	fmt.Println(cache.CacheManager.Set("name", []byte("wgp"), &cache.Options{
		Expiration: time.Duration(30) * time.Second,
	}))
	ctx.String(200, "ok")
}
